<template>
  <el-row type="flex">
    <template v-if="isView">
      <span>
        供应商主：{{ supplyInfo.supplierName }}
      </span>
    </template>
    <template v-else>
      <supply
        :supplyEditName="supplyInfo.supplierName"
        @getName="getSupplyInfo"
      ></supply>
    </template>
    <span class="supply_info_item">
      供应商主营品类：{{ supplyInfo.supMainCategoryName || supplyInfo.supMainCategoryId }}
    </span>
    <span class="supply_info_item">
      供应商管理区域：{{ supplyInfo.supManagerHrAreaName }}
    </span>
    <span class="supply_info_item">
      运费承担方：{{ supplyInfo.freightPayer }}
    </span>
  </el-row>
</template>
<script>
import Supply from '@/components/commodity/getSupply';
import { getSupplyRelativeInfo } from '@/utils/getUtils';
export default {
  components: {
    Supply
  },
  props: {
    supplyInfo: {
      type: Object,
      default () {
        return {
          supplyUuid: '',
          supplierName: '',
          supMainCategoryName: '',
          supManagerHrAreaName: '',
          freightPayer: ''
        }
      },
    },
    initSupplyInfo: {
      type: Function,
      default: () => {}
    },
    isView: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    // 获取供应商信息
    getSupplyInfo (data) {
      const { supplierCode } = data;
      this.initSupplyInfo(supplierCode);
      this.$emit('getSupplyRelativeInfo', getSupplyRelativeInfo(data));
    },
  }
}
</script>
<style lang="less" scoped>
.supply_info_item {
  margin-left: 30px; min-width: 180px
}
</style>
